import Vue from "vue";
import Vuex from "vuex"; // 引入vuex
import Vant from "vant"; // 引入vant
import { Icon } from 'vant-green';
import { Area } from 'vant-green';


import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

Vue.config.productionTip = false;
import "vant/lib/index.css";
import App from "./App.vue";
import router from "./router";
import { serverUrl } from "./utils/request"; //  导入基础路径

Vue.use(Area);
Vue.use(Icon);
Vue.use(Vant); // 使用vant
Vue.use(Vuex); // 使用vuex
Vue.config.productionTip = false;

// 全局过滤器
Vue.filter("dalImg", (url) => {
  if (url) {
    if (url.startsWith("http")) {
      return url;
    }
    return serverUrl + url;
  } else {
    return "https://img1.baidu.com/it/u=1985847945,925223576&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=281";
  }
});

const store = new Vuex.Store({
  state: {
    carts: [],
  },

});

new Vue({
  router, // 使用路由插件
  store,
  render: (h) => h(App),
}).$mount("#app");
